<template>
	<view class="">
		<view class="contant">
			<view class="sidebox">
				<van-sidebar active-key="activeKey">
					<van-sidebar-item v-for="(item,index) in leixlist" :key=index :title="item.name"
						@click="onChange(item)" />
				</van-sidebar>
			</view>

			<view class="rightbox">
				<view class="ad" v-if="tupian">
					<image :src="tupian" mode=""></image>
				</view>
				<view class="" v-for="(item,index) in contentlist" :key="index" @click="leixing(item)">
					<view class="title">
						{{item.name}}
					</view>
					<view class="conts">
						<view class="smallbox" v-for="(items,indexs) in item.child" :key="indexs">
							<view class="imgbox">
								<image :src="items.img" mode=""></image>
							</view>
							<view class="texts">
								{{items.name}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getclassification
	} from "../../api/api/index.js"
	export default {
		data() {
			return {
				// 头部导航栏
				background: {
					backgroundImage: "linear-gradient(90deg, #FF7E65, #FF3335)"
				},

				leixlist: [],
				activeKey: 0,
				tupian: "",
				contentlist: []
			}
		},
		methods: {
			public() {
				getclassification().then(res => {
					this.leixlist = res.data
					this.tupian = res.data[0].propaganda_img
					this.contentlist = res.data[0].child
				})
			},
			onChange(e) {
				this.tupian = e.propaganda_img
				this.contentlist = e.child
			},
			leixing(v) {
				this.jumpLink({
					link: "/pages/product_list/index",
					query: {
						id: v.id
					}
				})
			}
		},
		onLoad() {
			this.public()
		}
	}
</script>

<style scoped lang="scss">
	.contant {
		display: flex;

		.sidebox {
			width: 148rpx;
			background-color: #FFFFFF;
			position: fixed;
			top: 0;
			bottom: 0;
			left: 0;
		}

		.rightbox {
			width: 602rpx;
			margin-left: 148rpx;

			.ad {
				margin-top: 23rpx;
				margin-left: 32rpx;

				image {
					width: 560rpx;
					height: 180rpx;
				}
			}

			.title {
				margin-left: 32rpx;
				color: #282828;
				font-size: 30rpx;
				font-weight: 700;
				font-family: SourceHanSansCN;
				margin-top: 20rpx;
			}

			.conts {
				display: flex;
				flex-wrap: wrap;
				margin-left: 32rpx;
				margin-top: 30rpx;

				.smallbox {
					margin-right: 20rpx;
					margin-bottom: 20rpx;

					.imgbox {
						width: 120rpx;
						height: 120rpx;
						border: 1rpx solid #D1D1D1;

						image {
							width: 120rpx;
							height: 120rpx;
						}
					}


					.texts {
						text-align: center;
						color: #282828;
						font-size: 24rpx;
						font-family: Source Han Sans CN;
						margin-top: 10rpx;
					}
				}
			}

		}
	}
</style>
